<template>
    <div>
        <div class="itembox">
            <el-table :data="feedback" style="width: 100%;margin-top: 10px;">
                <el-table-column label="名称" width="180" property="name" />
                <el-table-column property="feedback.feedbackContent" label="反馈内容" width="200"
                    style="word-wrap: break-word;" />
                <el-table-column property="phoneNumber" label="联系电话" width="200" />
                <el-table-column property="email" label="反馈用户邮箱" width="200" />
                <el-table-column label="反馈时间" width="180" property="feedback.feedbackTime" />
                <el-table-column label="操作">
                    <template #default="scope">
                        <el-button type="success" size="medium" @click="handleFeedback(scope.$index, scope.row)">
                            待解决
                        </el-button>
                        <!-- <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">
                            删除
                        </el-button> -->
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>
<script>
import req from '@/utils/request';

export default {
    components: {

    },
    data() {
        return {
            feedback: [],
        }
    },
    computed: {

    },
    watch: {

    },
    mounted() {
        req.get("/cuisineFeedback/list").then(res => {
            this.feedback = this.feedback.concat(res.data);
            // console.log(this.feedback);
            req.get("/attractionFeedback/list").then(res2 => {
                this.feedback = this.feedback.concat(res2.data);

                // this.feedback  += res.data;
            })
        })

    },
    methods: {
        handleFeedback(index, row) {
            var email = row.email;
            var name = "“"+row.name+"”";
            var id = row.feedback.id;
            if (row.index == 1) {
                req.delete("/attractionFeedback/remove/" + id).then(res => {
                    this.feedback.splice(index, 1);
                    req.get("/email/sendValidateCode",{"mail":email,"name":name})
                    this.$emit("handleLoading")
                })
            }
            if (row.index == 2) {
                req.delete("/cuisineFeedback/remove/" + id).then(res => {
                    this.feedback.splice(index, 1);
                    req.get("/email/sendValidateCode",{"mail":email,"name":name})
                    this.$emit("handleLoading")
                })
            }
            console.log(row);

        },
        // 2秒加载
        handleLoading() {
            this.loading = true;
            setTimeout(() => {
                this.loading = false;
                location.reload();
            }, 1000);
        },
    }
};
</script>
<style scoped>
.itembox {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}
</style>